import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn, OneToMany,  } from "typeorm";
import { ManualTimestamp } from "../decorators/manual-timestamp.decorator";
import { DeputyGeneralBase } from "./deputy-general-base.entity";
import { DeputyGeneralSkillLearned } from "./deputy-general-skill-learned.entity";
import { DeputyGeneralEquipment } from "./deputy-general-equipment.entity";
import { DeputyGeneralStone } from "./deputy-general-stone.entity";

@Entity("deputy_general")
@ManualTimestamp()
export class DeputyGeneral {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column({ type: "int", comment: "基础表id" })
  base_id!: number;

  @Column({
    type: "decimal",
    precision: 4,
    scale: 2,
    default: 0,
    comment: "成长率",
  })
  czl!: number;

  @Column({ type: "int", default: 0, comment: "速度" })
  sp!: number;

  @Column({ type: "int", default: 0, comment: "攻击力" })
  ap!: number;

  @Column({ type: "int", default: 0, comment: "血量" })
  hp!: number;

  @Column({ type: "int", default: 0, comment: "精力" })
  mp!: number;

  @Column({ type: "int", default: 0, comment: "加点速点数" })
  sp_points!: number;

  @Column({ type: "int", default: 0, comment: "加点攻点数" })
  ap_points!: number;

  @Column({ type: "int", default: 0, comment: "加点血点数" })
  hp_points!: number;

  @Column({ type: "int", default: 0, comment: "加点精点数" })
  mp_points!: number;

  @Column({ type: "int", default: 100, comment: "忠诚度(0-100)" })
  loyalty!: number;

  @Column({ type: "int", default: 0, comment: "默契度(0-20万)" })
  compatibility!: number;

  @Column({ type: "boolean", default: true, comment: "是否为真" })
  is_real!: boolean;

  @Column({ type: "int", default: 0, comment: "转职次数(0-4)" })
  trans_count!: number;

  @Column({
    type: "int",
    default: 1,
    comment: "职业类型(1:武士,2:文人,3:异师)",
  })
  roleType!: number;

  @Column({ type: "int", default: 0, comment: "星级(0-5)" })
  star!: number;

  @Column({ type: "int", default: 1, comment: "等级" })
  lvl!: number;

  @Column({ type: "bigint", default: 0, comment: "升级还需要的经验值" })
  exp!: number;

  @Column({ type: "int", nullable: true, comment: "无双1id" })
  ultimate_skill_1_id!: number;

  @Column({ type: "int", default: 0, comment: "无双1等级" })
  ultimate_skill_1_level!: number;

  @Column({ type: "int", nullable: true, comment: "无双2id" })
  ultimate_skill_2_id!: number;

  @Column({ type: "int", default: 0, comment: "无双2等级" })
  ultimate_skill_2_level!: number;

  @Column("datetime", { comment: "创建时间" })
  created_at!: Date;

  @Column("datetime", { comment: "更新时间" })
  updated_at!: Date;

  @ManyToOne(() => DeputyGeneralBase)
  @JoinColumn({ name: "base_id" })
  base!: DeputyGeneralBase;

  @OneToMany(() => DeputyGeneralSkillLearned, (skill) => skill.deputy)
  skills!: DeputyGeneralSkillLearned[];

  @OneToMany(() => DeputyGeneralEquipment, (equipment) => equipment.deputy)
  equipments!: DeputyGeneralEquipment[];

  @OneToMany(() => DeputyGeneralStone, (stone) => stone.deputy)
  stones!: DeputyGeneralStone[];
}
